<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

String site_url = request.getServerName().replace("http://","");

String login_id = null;
String user_id = null;
String level = null; 
String admin_ent_id = null;

if(userSession!= null){
	login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
	level = userSession.getAdmin_level();
	admin_ent_id = userSession.getEnt_id();
}

String test_state 	= CommonUtil.nvl(request.getParameter("test_state"),"");
String rating_state 	= CommonUtil.nvl(request.getParameter("rating_state"),"");

String search_combo 	= CommonUtil.nvl(request.getParameter("search_combo"),"");
String keyword 		= CommonUtil.nvl(request.getParameter("keyword"),"");
String line_number	= CommonUtil.nvl(request.getParameter("line_number"),"10");
//페이징 처리 Start
//페이지 표시정보 받기 혹은 검색입력창
String curr_page = CommonUtil.nvl(request.getParameter("curr_page"),"1");

String one_group = CommonUtil.nvl(request.getParameter("one_group"),"10");
String total_count = CommonUtil.nvl(request.getParameter("total_count"),"0");
//페이징 처리 End

String ent_id	= CommonUtil.nvl(request.getParameter("ent_id"),""); 
String gubun	= CommonUtil.nvl(request.getParameter("gubun"),""); 
String start_date	= CommonUtil.nvl(request.getParameter("start_date"),""); 
String end_date	= CommonUtil.nvl(request.getParameter("end_date"),"");

/*
if(gubun.equals("")){
	gubun = "OPIC";
}
*/
HashMap listMap=(HashMap)request.getAttribute("list_map");

HashMap map  = null;
ArrayList list=null;

HashMap map_1  = null;
ArrayList list_1=null;

HashMap map_2  = null;
ArrayList list_2=null;

String reg_dt 	= "";
String reg_dt_time 	= "";
String opic_gubun 	= "";
String reg_cnt 		= "";
String per_cnt	= "";

String s_total_cnt	= "0";
String s_give_before_cnt	= "0";
String s_progress_cnt	= "0";
String s_end_cnt	= "0";
String s_holding_cnt	= "0";
String v_start_date	= ""; 
String v_end_date	= "";

String member_test_code 		= "";
String member_id 		= "";
String test_state_list 		= "";
String test_state_str 		= "";
String test_state_holding = "";
String login_id_map 		= "";
String login_name 	= "";
String email	= "";
String cell_no	= "";
String result_code	= "";

String sign_date 		= "";
String sign_state 		= "";

String rater_id	= "";
String rating_state_list	= "";
String rating_start_time	= "";
String rating_close_time	= "";
String rating_reg_dt	= "";

String rerating_member_test_code	= "";
String rerating_gubun	= "";
String rerating_reason	= "";

String ent_nm="";

String pause_yn="";
String test_break_yn="";

String rating_true="";
String end_dt="";

String r_num="";

if (listMap!=null){
   
    list_2=(ArrayList)listMap.get("mainContent_2");
}



if(list_2 != null){
	if(list_2.size() > 0){
		total_count = (String)((HashMap)list_2.get(0)).get("total_row");
		System.out.println("total_count ========> " + total_count);
	}
}

if(list_2.size() == 0){
	total_count = "0";
}

if(start_date.equals("")){
	start_date = v_start_date;
}

if(end_date.equals("")){
	end_date = v_end_date;
}

String[] start_date_arr = start_date.split("-");
String[] end_date_arr = end_date.split("-");
%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<style>
body{background-color:#fff;background:#ffffff}
</style>
<script language='javascript' src="/js/ajaxutil.js"></script>
<script language='javascript' src="/js/calendar.js"></script>
<script>
function go_result(ad,g){
	var frm = document.mainform;
	frm.member_test_code.value= ad;
	
	//alert('http://'+document.domain+'/opictest_result.jsp?member_test_code=');
	
	
	var popw = 870;
	var poph = 700
	
	var popleft = (screen.width - popw)/2;
	var poptop = (screen.height - poph)/2;
	
	var open_opictest = window.open('','opicresult','width='+popw+',height='+poph+',resizable=no,scrollbars=yes,top='+poptop+',left='+popleft);
	open_opictest.focus();
	
	var s_str=document.domain.replace("admin","");
	
	if(g == "OPIC"){
		/*
		frm.cmd.value="opictest_result";
		frm.action = '/speaking.pb';
		*/
		var url = 'http://'+s_str+'/opictest_result.jsp';
		frm.action = url;
	}else{
		/*
		frm.cmd.value="tstest_result";
		frm.action = '/speaking.pb';
		*/
		var url = 'http://'+s_str+'/tstest_result.jsp';
		frm.action = url;
	}	
	
	frm.target= 'opicresult';              
	frm.submit();	
	
	
	frm.action = '';
	frm.target= ''; 
	
}

function go_log(m){
	var frm = document.mainform;
	frm.member_id.value= m;
	
	var popw = 1100;
	var poph = 500
	
	var popleft = (screen.width - popw)/2;
	var poptop = (screen.height - poph)/2;
	
	var open_opiclog = window.open('','opiclog','width='+popw+',height='+poph+',resizable=no,scrollbars=yes,top='+poptop+',left='+popleft);
	open_opiclog.focus();
	
	frm.cmd.value='member_test_first_log';
	frm.action = '/speaking.pb';
	frm.target= 'opiclog';              
	frm.submit();	
	
	
	frm.action = '';
	frm.target= '';     
}

//검색
//검색
function go_search(){
	var frm = document.mainform;
	/*
	if(frm.search_combo.value==''){
		alert('검색구분을 선택하세요.');
		return;
	}
	*/
	frm.cmd.value='statistics_ent_3';
	frm.curr_page.value ="1";
	frm.total_count.value="0";
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
}

function go_opictest(){
	//go_search();
	var frm = document.mainform;	
	frm.cmd.value='statistics_ent_3';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();
}

function go_tstest(){
	//go_search()
	var frm = document.mainform;	
	frm.cmd.value='statistics_ent_3';
	frm.action = '/speaking.pb';
	frm.target= '_self';              
	frm.submit();
}


function go_excel(){
	var frm = document.mainform;	
	frm.action = '/jsp/sp_sp0501_ent_excel.jsp';
	frm.target= 'hidden_frm';              
	frm.submit();	
}

function go_rerating(code,g){
	var frm = document.mainform;
	if(confirm('재응시 처리를 하시겠습니까?')){
		frm.member_test_code.value = code;
		
		if(g == "OPIC"){
			frm.cmd.value="opictest_rerating";
		}else{
			frm.cmd.value="tstest_rerating";
		}
		frm.action = '/speaking.pb';
		frm.target= 'hidden_frm';              
		frm.submit();	
	}
}
function go_delete(ad,g){
	var frm = document.mainform;
	if(confirm('삭제 하시겠습니까?')){
	frm.member_test_code.value= ad
	if(g == "OPIC"){
		frm.cmd.value="opictest_delete";
	}else{
		frm.cmd.value="tstest_delete";
	}
	frm.action = '/speaking.pb';
	frm.target= 'hidden_frm';              
	frm.submit();
	}
}

function go_refund(ad,g){
	var frm = document.mainform;
	if(confirm('환불 하시겠습니까?')){
	frm.member_test_code.value= ad;
	frm.test_state_change.value= 'R';
	if(g == "OPIC"){
		frm.cmd.value="opictest_reteststate";
	}else{
		frm.cmd.value="tstest_reteststate";
	}
	frm.action = '/speaking.pb';
	frm.target= 'hidden_frm';              
	frm.submit();
	}
}
//페이지 번호를 눌렸을때.
function go_page(page){
	var frm = document.mainform;
	frm.cmd.value='statistics_ent_3';
	frm.curr_page.value = page ;			
	frm.total_count.value = "<%=total_count%>";
	frm.keyword.value = "<%=keyword%>";
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
}
</script>


<form name="mainform"  method="post" action = "/speaking.pb" >
<input type="hidden" name="start_date" value="<%=start_date %>">
<input type="hidden" name="end_date" value="<%=end_date %>">
<input type="hidden" name="ent_id" value="<%=ent_id %>">
<input type="hidden" name="gubun" value="<%=gubun %>">

<input type="hidden" name="test_state" value="<%=test_state %>">
<input type="hidden" name="rating_state" value="<%=rating_state %>">
<input type="hidden" name="search_combo" value="<%=search_combo %>">
<input type="hidden" name="keyword" value="<%=keyword %>">

<input type="hidden" name="test_state_change" value="">
	<div id="bodyContainer">
        <div id="contents">
          
          
          
          
          <div class="boxContainer">
            <dl title="응시자목록">
              <dt>응시자목록 [Total : <font style="color:red"><%=total_count %></font>]</dt>
            </dl>
            <table class="listTb" style='table-layout:fixed'>
              <tr>
                <th>번호</th>
                <th style="text-overflow:ellipsis; overflow:hidden; ">이름</th>
                <th style="text-overflow:ellipsis; overflow:hidden; ">아이디</th>
                <th style="text-overflow:ellipsis; overflow:hidden; width:50px">소속기업</th>
                <th>구분</th>
                <th>응시일<br>(종료일)</th>
                <th style="width:50px">시험상태</th>                
                <th style="width:50px">채점상태</th> 
                <th>재응시<Br>상태</th>
                <%if(!level.equals("5")){ %>
                <th>재응시<Br>처리</th>  
                <%} %>              
                <th style="width:50px">시험결과</th>
              </tr>
<%               

    if (list_2!=null && list_2.size()> 0) {
    	for(int i=0; i<list_2.size(); i++){
	      map_2=(HashMap)list_2.get(i);
	      r_num = CommonUtil.nvl((String)map_2.get("r_num"));
	      member_test_code = CommonUtil.nvl((String)map_2.get("member_test_code"));
	      member_id = CommonUtil.nvl((String)map_2.get("member_id"));
	      login_id_map = CommonUtil.nvl(Crypto.DecodeBySType((String)map_2.get("login_id")));
	      login_name = CommonUtil.nvl((String)map_2.get("login_name"));
	      email = CommonUtil.nvl((String)map_2.get("email"));
	      cell_no = CommonUtil.nvl((String)map_2.get("cell_no"));
	      reg_dt = CommonUtil.nvl((String)map_2.get("reg_dt"));
	      reg_dt_time = CommonUtil.nvl((String)map_2.get("reg_dt_time"));
	      opic_gubun = CommonUtil.nvl((String)map_2.get("gubun"));
	      
	      test_state_list = CommonUtil.nvl((String)map_2.get("test_state"));
	      test_state_str = CommonUtil.nvl((String)map_2.get("test_state_str"));
	      test_state_holding = CommonUtil.nvl((String)map_2.get("test_state_holding"));
	      
	      
	      sign_date = CommonUtil.nvl((String)map_2.get("sign_date"));
	      sign_state = CommonUtil.nvl((String)map_2.get("sign_state"));
	      
	      result_code = CommonUtil.nvl((String)map_2.get("result_code"));
	       
	      rater_id = CommonUtil.nvl((String)map_2.get("rater_id"));
	      rating_state_list = CommonUtil.nvl((String)map_2.get("rating_state"));
	      rating_start_time = CommonUtil.nvl((String)map_2.get("rating_start_time"));
	      rating_close_time = CommonUtil.nvl((String)map_2.get("rating_close_time"));
	      rating_reg_dt = CommonUtil.nvl((String)map_2.get("rating_reg_dt"));
	      
	      rerating_member_test_code = CommonUtil.nvl((String)map_2.get("rerating_member_test_code"));
	      rerating_gubun = CommonUtil.nvl((String)map_2.get("rerating_gubun"));
	      rerating_reason = CommonUtil.nvl((String)map_2.get("rerating_reason"));
	      
	      
	      ent_nm = CommonUtil.nvl((String)map_2.get("ent_nm"));
	      
	      pause_yn = CommonUtil.nvl((String)map_2.get("pause_yn"));
	      test_break_yn = CommonUtil.nvl((String)map_2.get("test_break_yn"));
	      
	      rating_true = CommonUtil.nvl((String)map_2.get("rating_true"));
	      end_dt = CommonUtil.nvl((String)map_2.get("end_dt"));
	      
%>             
			  <tr>
                <td width=50 height="22"><%=r_num %></td>
                <td width=70 height="22" style="text-overflow:ellipsis; overflow:hidden; " title="<%=login_name %>"><nobr><a href="#" onclick="go_log('<%=member_id%>')"><%=login_name %></a></nobr></td>
                <td width=70 height="22" style="text-overflow:ellipsis; overflow:hidden; " title="<%=login_id_map %>"><nobr><%=login_id_map %></nobr></td>
                <td width=70 height="22" style="text-overflow:ellipsis; overflow:hidden; " title="<%=ent_nm %>"><nobr><%=ent_nm %></nobr></td>
                <td width=70 height="22"><%=opic_gubun %></td>
                <td width=70 title="<%=reg_dt_time %>" height="22"><%=reg_dt %>
                <%=(!end_dt.equals("")?"<br>("+end_dt+")":"") %></td> 
                <td width=70 height="22">
				<%if (test_state_list.equals("R")){%>
								<font color="#CC0099" style="font-size:10pt"><b>환불</b></font>  
				<%}else if (test_state_list.equals("2")){%>
								<font color="#0064FF" style="font-size:10pt"><b>완료</b></font>
                <!--img src="img/btn2_end.gif" alt="완료" border="0" /-->				 
				<%}else if(test_break_yn.equals("Y")){ %>
								<font color="red" style="font-size:10pt"><b>시험중단</b></font>
				<%}else if(pause_yn.equals("Y")){ %>
								<font color="#006400" style="font-size:10pt"><b>일시정지</b></font>				
                <!--img src="img/btn2_ing.gif" alt="진행중" border="0" /-->	
                <%}else if (test_state_list.equals("Holding")){%>
								<font color="#CC0000" style="font-size:10pt"><b>보류</b></font>       
								<!--img src="img/btn2_holding.gif" alt="홀딩" border="0" /-->			
				<%}else if(test_state_list.equals("1")){ %>
								<font color="#008080" style="font-size:10pt"><b>진행중</b></font>
                <!--img src="img/btn2_ing.gif" alt="진행중" border="0" /-->
                <%}else if (test_state_list.equals("0")){%>
								<font color="#FFA500" style="font-size:10pt"><b>진행전</b></font>
                <!--img src="img/btn2_before.gif" alt="진행전" border="0" /-->
                
                
                <%}else if (test_state_list.equals("9")){%>
								<font color="#3C5A91" style="font-size:10pt"><b>재시험</b></font>
                <!--img src="img/btn2_retest.gif" alt="재시험" border="0" /-->
                <%}else{ %>
                <%=test_state_list %>
                <%} %>
                
                <%if (rating_true.equals("N")){%>
				<br><font color="#9400D3" style="font-size:10pt"><b>(무채점)</b></font>
				<%} %>
				</td> 
                <td width=70 height="22">
                <%if(rating_state_list.equals("1")){ %>
								<font color="#008080" style="font-size:10pt"><b>진행중</b></font>
                <!--img src="img/btn3_progress.gif" alt="진행중" border="0" /-->
                <%}else if (rating_state_list.equals("2")){%>
								<font color="#0064FF" style="font-size:10pt"><b>완료</b></b></font>
                <!--img src="img/btn3_complete.gif" alt="완료" border="0" /-->
                <%}else if (rating_state_list.equals("9")){%>
								<font color="#3C5A91" style="font-size:10pt"><b>재시험</b></font>
                <!--img src="img/btn3_retest.gif" alt="재시험" border="0" /-->
                <%}else if (rating_state_list.equals("Holding")){%>
								<font color="#CC0000" style="font-size:10pt"><b>보류</b></font>       
                <!--img src="img/btn3_holding.gif" alt="홀딩" border="0" /-->
                <%}else if (rating_state_list.equals("0") && test_state_list.equals("2")){ %>
								<font color="#FFA500" style="font-size:10pt"><b>진행전</b></font>
                <!--img src='img/btn3_ready.gif' alt='레디' border="0" /-->
                <%} %>
                </td>
                <td width=70 height="22">
                <%=(!rerating_member_test_code.equals(""))?"<font color=\"#3C5A91\" style=\"font-size:10pt\"><b>재시험</b></font>":"" %>
                <%=(rerating_gubun.equals("1"))?"<br><font style=\"font-size:10pt\"><b>UnRating</b></font>":"" %>
                </td>
                <!--td width=70><%=(!rerating_member_test_code.equals(""))?"<img src='img/btn2_retest.gif' alt='재시험' border='0' />":"" %></td-->
                <%if(!level.equals("5")){ %>
                <td width=70 height="22">
                <%if(!rating_state_list.equals("2") && (test_state_list.equals("1") || test_state_list.equals("Holding") ) || test_state_list.equals("2")){//|| test_state_list.equals("2")%>
                <a href="#" onclick="go_rerating('<%=member_test_code%>','<%=opic_gubun%>')"><img src="img/btn2_retest2.gif" alt="재시험" border="0" /></a><%} %></td>
                <%} %>
                
                <!--  <td><%if(!result_code.equals("")){ %><a href='#' onclick="go_result('<%=member_test_code%>')">바로가기</a><%} %></td> -->
                <td width=70 height="22"><%if(test_state_list.equals("2") || test_state_list.equals("8")){ %><a href='#' onclick="go_result('<%=member_test_code%>','<%=opic_gubun%>')"><img src='img/btn2_direct.gif' alt='바로가기' border="0" /></a><%} %>
                <%if(level.equals("1") || level.equals("2")){ %>
                <br>
                <a href="#" onclick="go_delete('<%=member_test_code%>','<%=opic_gubun%>')">[삭제]</a>
                <a href="#" onclick="go_refund('<%=member_test_code%>','<%=opic_gubun%>')">[환불]</a>
                <%} %>
                </td>
              </tr>
<%	      
    	}
      
    }else{

%> 
    				<tr>
    	                <td colspan=11 align=center>응시리스트가 없습니다.</td>
    	            </tr>
<%
   }
%>
            </table>
            
            <!-- 페이징 -->
            <div class="paging"><common:pagelistnew currPage="<%=curr_page%>" total="<%=total_count%>" onePage="<%=line_number%>" oneGroup="<%=one_group%>"/></div>
            <!-- //페이징 -->
          </div>  
        </div>
      </div>


<input type="hidden" name="cmd" value="">
<input type="hidden" name="member_id" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">
<input type="hidden" name="member_test_code" value="">
<input type="hidden" name="line_number" value="<%=line_number%>">
<input type="hidden" name="curr_page" value="<%=curr_page%>">
<input type="hidden" name="total_count" value="<%=total_count%>">
</form>

<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>

<script>
parent.document.mainform.e_total_count.value = "<%=total_count%>";
parent.document.all["ent_list_3"].style.height  = 600;
</script>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
